#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START etc

if [ "x${BLINUX_BUILD_ID}" = 'x' ]; then
	BLINUX_BUILD_ID=$(git rev-parse HEAD)
fi
if [ "x${BLINUX_BUILD_DATE}" = 'x' ]; then
	BLINUX_BUILD_DATE=$(env LC_ALL=C date +%Y%m%d)
fi

rm -rf build/etc
cp -a etc build/
sed -r -e "s/@DATE@/$BLINUX_BUILD_DATE/g" -i build/etc/lsb-release

# install basic config files
mkdir -p -m 755 "$stage/etc"
cd build
find etc -type f | cpio -pumd "$stage"
cd ../..
rm -rf build/etc

# create mount points
for mntpt in boot dev home media mnt opt proc run srv sys tmp; do
	mkdir -p -m755 "$stage/$mntpt"
done
# create /root directory
mkdir -p -m700 "$stage/root"
# create /boot/efi directory
mkdir -p -m700 "$stage/boot/efi"

# RECIPE END etc
